#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
    int jewelleryValue(vector<vector<int>>& frame) {
        int n = frame.size(),m = frame[0].size();
        vector<vector<int>> dp(n+1,vector<int>(m+1));
        for(int i = 1;i<n+1;++i)
        {
            for(int j = 1;j<m+1;++j)
            {
                int maxprice = std::max(dp[i-1][j], dp[i][j-1]);
                dp[i][j] = maxprice + frame[i-1][j-1];
            }
        }
        return dp[n][m];
    }
};